// pages/mysever02/mysever02.js
const app = getApp()
const common = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  getPhoneNumber(e) {
    wx.showLoading({
      title: "加载中",
      mask: true
    });
    let that = this;
    if(!e.detail.code) {
      wx.showToast({
        title: '注册失败',
        icon: "none",
      });
      return
    }
    common.getData_user(common.config.GetPhoneNumber, {
      code: e.detail.code
    }, "post", function (res) {
      let userInfo = wx.getStorageSync("userInfo");
      userInfo.phone = res;
      wx.setStorageSync('userInfo', userInfo)
      that.onRegister()
    });
  },
  onRegister() {
    common.getData_user(common.config.RegisterRunner, {}, "post", function () {
      wx.hideLoading();
      wx.showToast({
        title: '恭喜注册成功',
      });
      wx.navigateBack()
    });
  }
})